cmake_minimum_required(VERSION 3.8)
project(DENN)

set(CMAKE_CXX_STANDARD 14)
#add debug prefix
if(NOT CMAKE_DEBUG_POSTFIX)
  set(CMAKE_DEBUG_POSTFIX d)
endif()

include_directories(include/)
include_directories(third_party/Eigen/include/)
file(GLOB denn_source source/*.cpp source/**/*.cpp source/**/**/*.cpp)
file(GLOB denn_include include/*.h include/**/*.h include/**/**/*.h)
SET(SOURCE_FILES ${denn_source} ${denn_include})

if(MSVC)
    include_directories(third_party/zlib/include/)
    set(CMAKE_CXX_FLAGS "/DNOMINMAX /DUSE_FAST_UNIFORM /EHsc ")    
    set(CMAKE_CXX_FLAGS_DEBUG "/D_DEBUG /MDd /Od /INCREMENTAL:NO /Zi")
    set(CMAKE_CXX_FLAGS_RELEASE "/O3 /DNDEBUG /MD ")
    add_executable(DENN ${SOURCE_FILES})
    target_link_libraries(DENN ${CMAKE_SOURCE_DIR}/third_party/zlib/lib/x64/zlibstatic.lib)
    target_link_libraries(DENN shlwapi.lib)
else()
    set(CMAKE_CXX_FLAGS "-DFLOAT -fPIC -D_FORCE_INLINES")
    set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g")
    set(CMAKE_CXX_FLAGS_RELEASE "-O3")
    find_package(ZLIB)
    find_library(M_LIB m)
    find_library(UTIL_LIB util)
    if(ZLIB_FOUND)
        add_executable(DENN ${SOURCE_FILES})
        include_directories(${ZLIB_INCLUDE_DIRS})
        target_link_libraries(DENN ${ZLIB_LIBRARIES})
        target_link_libraries(DENN ${M_LIB})
        target_link_libraries(DENN ${UTIL_LIB})
    else()
        message("Zlib not found")
    endif()
endif()